package com.zysd.collection.scheduler.service.channel;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zysd.collection.scheduler.dao.ChannelDao;
import com.zysd.collection.scheduler.entity.Channel;
import com.zysd.collection.scheduler.entity.ChannelState;
import com.zysd.collection.scheduler.entity.Terminal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 *
 * @author ht
 * @date 2017/3/9
 */
@Service
public class ChannelServiceImpl implements ChannelService {

    @Autowired
    private ChannelDao channelDao;

    @Override
    @Transactional
    public int updateById(Channel dto) {
        return channelDao.updateById(dto);
    }

    @Override
    @Transactional
    public int insert(Channel dto) {
        return channelDao.insert(dto);
    }

    @Override
    public Channel byId(Channel dto) {
        return channelDao.byId(dto);
    }

    @Override
    public Page<Channel> loginMsg(Integer region, Integer local, String startDate, Integer offset, Integer rows) {
        //PageHelper.startPage(offset ,rows);
        PageHelper.offsetPage(offset,rows);
        Page<Channel> page = channelDao.loginMsg(region,local,startDate);
        return page;
    }

    /**
     * 根据终端信息 查询所有终端状态信息
     *
     * @param conditions
     * @return
     */
    @Override
    public List<ChannelState> findTerminalOnline(List<Terminal> conditions) {
        return channelDao.findTerminalOnline(conditions);
    }

    @Override
    public List<ChannelState> findChannelOnline() {
        return channelDao.findChannelOnline();
    }
}
